{* $Id$ *}
{include_core file="admin/lib/header.html" title="商品分类管理"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">商品分类管理<span>在这里对商品进行管理</span></h2>
    <a href="{AnUrl('goods/admin/category/edit')}" class="btn btn-success btn-sm right"><i class="icon-add"></i>添加分类</a>
</div>
<!--start:列表-->
<div class="list-table-filters">
    <p>
        <span class="label label-info">安状态</span>
        <a href='{AnUrl("goods/admin/category?{URLTracker::set("status", 1)}")}' {if URLTracker::val('status') == 1}
        class="label label-primary" {else} class="label label-default" {/if}>正常</a>
        <a href='{AnUrl("goods/admin/category?{URLTracker::set("status", 0)}")}' {if URLTracker::val('status') == 0}
        class="label label-primary" {else} class="label label-default" {/if}>已删除</a>
    </p>
</div>
{include_core file="admin/lib/pager.html"}
<table class="list-table">
    <thead>
    <tr>
        <th>ID</th>
        <th>分类名称</th>
        <th>添加时间</th>
        <th>商品数量</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {foreach $goods_category as $k => $v}
    <tr>
        <td>
            {$v.id}
        </td>
        <td>
            {$v.title}
        </td>
        <td>
            {$v.add_time}
        </td>
        <td>
            {$v.goods_num}
        </td>
        <td>
            {if URLTracker::val('status') == 1}
            <a href='{AnUrl("goods/admin/category/edit?id={$v.id}")}' class="btn btn-info btn-xs"><i
                    class="icon-edit icon-white"></i>编辑</a>
            <a href='{AnUrl("goods/admin/category/change_status?id={$v.id}&status=0")}'
               class="btn btn-danger btn-xs js-delete"><i
                    class="icon-trash icon-white"></i>删除</a>
            {else}
            <a href='{AnUrl("goods/admin/category/change_status?id={$v.id}&status=1")}'
               class="btn btn-success btn-xs js-revise"><i
                    class="icon-trash icon-white"></i>恢复</a>
            {/if}
        </td>
    </tr>
    {foreachelse}
    <tr>
        <td class="txtleft" colspan="11">暂无数据</td>
    </tr>
    {/foreach}
    </tbody>
</table>
{include_core file="admin/lib/pager.html"}
<!--end:列表-->
<script>
    $('.list-table').on('click', '.js-delete', function (e) {
        e.preventDefault();
        var el = $(this);
        var num = parseInt(el.parent().prev().text());
        if (num > 0) {
            showMsg('无法删除, 该分类中含有商品');
            return false;
        } else if (num == 0) {
            showConfirm('确认删除', 1, function () {
                window.location = el.attr('href');
            });
        }
        return false;
    }).on('click', '.js-revise', function (e) {
        e.preventDefault();
        var el = $(this);
        showConfirm('确认恢复', 1, function () {
            window.location = el.attr('href');
        });
        return false;
    });
</script>
{include_core file="admin/lib/footer.html"}